package com.innovation.chengzhangriji.ui.widget;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.innovation.chengzhangriji.R;

public class ThemeViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    public interface OnSelectListener {
        void onSelect(ThemeViewHolder holder);
    }

    private OnSelectListener mOnSelectListener;

    private CuteTwoButton mCtbSelect;

    public ThemeViewHolder(View itemView) {
        super(itemView);
        mCtbSelect = (CuteTwoButton) itemView.findViewById(R.id.btn_select);
        mCtbSelect.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (mOnSelectListener != null) {
            mOnSelectListener.onSelect(this);
        }
    }

    public void setOnSelectListener(OnSelectListener onSelectListener) {
        mOnSelectListener = onSelectListener;
    }

    public void setText(String text) {
        mCtbSelect.setText(text);
    }

    public void setChange(boolean isSelect) {
        if (isSelect) {
            mCtbSelect.setTwoState();
        } else {
            mCtbSelect.setOneState();
        }
    }
}
